#!/usr/bin/env coffee

import fullscreen from '../fullscreen.coffee'
import destroy from '../destroy.coffee'


CONFIRM = ConfirmResolve = ConfirmPromise = undefined

new_promise = =>
  ConfirmPromise = new Promise (resolve)=>
    ConfirmResolve = resolve
    return
  return

new_promise()

resolve = (r)=>
  CONFIRM.once 'closed',=>
    ConfirmResolve(r)
    new_promise()
    return

  destroy CONFIRM
  return

export y = =>
  resolve true
  return

export n = =>
  resolve false
  return

export show = (name)=>
  CONFIRM = fullscreen['confirm_'+name](
    width:275
    height:190
    modal:true
    isAlwaysOnTop:true
    visibleOnAllWorkspaces:true
  )
  CONFIRM.setAlwaysOnTop(true,'screen-saver')
  ConfirmPromise
